<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>openGauss Blog  | openGauss入门（快速安装）</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    
    <link rel="shortcut icon" href="https://xzx666.gitee.io/lookeng/img/favicon.ico" type="image/x-icon" />
    <link rel="apple-touch-icon" href="https://xzx666.gitee.io/lookeng/img/apple-touch-icon.png" />

    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/commen.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/blog.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/mobile.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/pagination.css?t=1607593672000">
    
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?34e9f585f29581007941aa1698181871";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
</head>
<body>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>






<div class="container">
    <div class="columns blog-detail">
        <div class="post_detail">
            <div class="is-child box">
                <div class="breadCrumb"><a href="\zh\">博客/</a></div>
                <div class="blog-detail-header">
                    <h1>openGauss入门（快速安装）</h1>
                    <div class="blog-detail-prop">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-date.png">
                        <span class="article_right_date">2020-07-11</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-author.png">
                        <span class="article_right_author">hemny</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-view.png">
                        <span id="/zh/post/hemny/2020-07-11_quickinstall/" class="leancloud_visitors" data-flag-title="openGauss入门（快速安装）">
                            <i class="leancloud-visitors-count"></i>                     
                        </span>
                    </div>
                    <div class="blog-detail-tags">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-tag.png">
                        
                        <a href="https://xzx666.gitee.io/lookeng/zh/tags/opengauss%E5%85%A5%E9%97%A8">openGauss入门</a>
                        
                    </div>
                </div>
                <div class="content blog-content">
                    

<h3 id="前言">前言</h3>

<p>最近看到openGauss开源了，试用了一下，总感觉安装时要配置XML太麻烦，所以用了简单的安装办法，绿色最小化安装，作为尝鲜者试用方便。</p>

<h3 id="系统环境">系统环境</h3>

<pre><code>硬件：X86平台，4GB内存
系统：CentOS7  minimal
</code></pre>

<h3 id="安装软件步骤">安装软件步骤</h3>

<hr />

<ol>
<li><p>root用户 安装wget、bzip2</p>

<pre><code>yum -y install wget bzip2
</code></pre></li>

<li><p>创建gauss用户</p>

<pre><code>useradd -m gauss
su - gauss
</code></pre></li>

<li><p>解压安装openGauss</p>

<pre><code># 设置环境变量
export GS_HOME=/home/gauss/opengauss
export LD_LIBRARY_PATH=$GS_HOME/lib:$LD_LIBRARY_PATH
export PGDATA=/home/gauss/data
export PATH=$GS_HOME/bin:$PATH

# 安装openGauss，两次加压是由于官网下载的安装包是为官方安装工具准备的，经过两次压缩。
mkdir tmp &amp;&amp; cd tmp
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.0.0/x86/openGauss-1.0.0-CentOS-64bit.tar.gz
tar xf openGauss-1.0.0-CentOS-64bit.tar.gz
mkdir -p $GS_HOME &amp;&amp; cd $GS_HOME
tar xf /home/gauss/tmp/openGauss-1.0.0-CentOS-64bit.tar.bz2

# 此时可以删除临时目录/home/gauss/tmp
rm -rf /home/gauss/tmp
</code></pre></li>
</ol>

<h3 id="初始化数据库">初始化数据库</h3>

<p>这里直接采用gs_initdb命令初始化。</p>

<pre><code>gs_initdb -w Aa123456 --nodename='sgnode'

# 配置数据库
# vi $PGDATA/postgresql.conf 追加
listen_addresses = '*' 
local_bind_address = '0.0.0.0'
port = 5432 

# 配置hba文件
# vi $PGDATA/pg_hba.conf  追加以下内容 
host    all             all             0.0.0.0/0               sha256

</code></pre>

<h3 id="启动数据库">启动数据库</h3>

<pre><code>gs_ctl start -l logfile
</code></pre>

<p>#初始化用户
PS：初始化数据库的用户，是不能通过IP远程连接的哦，所以需要创建另外一个用户才能远程连接，不知道有没有其他参数可以解除初始化用户的远程连接限制。</p>

<pre><code># openGauss是源于PostgreSQL的数据库，默认初始化postgres数据库不变，如果当前用户不是postgres就要指定数据库名登录
gsql -dpostgres

# 修改初始化用户的密码（若需要），openGauss 加强安全，如果需要修改初始化数据库用户的密码，需要用REPLACE哦！
postgres=#  ALTER ROLE gauss IDENTIFIED BY 'Aa1234567' REPLACE 'Aa123456';

# 创建用户(初始化数据库的用户不能进行远程连接，需要重新创建用户)
postgres=# create user user1 with password 'Aa123456';
postgres=# grant all PRIVILEGES to user1; 

</code></pre>

<h3 id="验证远程登录数据库">验证远程登录数据库</h3>

<p>gsql -dpostgres -h192.168.1.67 -Uuser1</p>

<h3 id="总结">总结</h3>

<p>openGauss数据库安装也可以参考postgresql的安装方式进行绿色安装。需要注意的是，openGauss对安全性进行了增强，所以在初始化数据库是需要数据密码，并且初始化数据库的用户是不能远程登录的，后面需要重新初始化一个远程登录使用的用户。</p>

                </div>
            </div>
            <div class="box" style="margin-top:15px;">
                <div style="font-size:14px;color:gray"><strong>【免责声明】</strong>本文仅代表作者本人观点，与本网站无关。本网站对文中陈述、观点判断保持中立，不对所包含内容的准确性、可靠性或完整性提供任何明示或暗示的保证。本文仅供读者参考，由此产生的所有法律责任均由读者本人承担。</div>
            </div>
            <div class="post-comment">
                
                  
  <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/custom.css" />
  <div id="vcomments" lang="zh-cn" mess="说点什么吧..."></div>

  <script type="text/javascript">
    const placeholder = document.getElementById("vcomments").getAttribute("mess"),
          lang = document.getElementById("vcomments").getAttribute("lang");
    const  langs = lang == "zh-cn" ? "zh-cn" : "en";
    new Valine({
        el: '#vcomments' ,
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm', 
        placeholder: placeholder,
        visitor: true,
		    meta: ['nick','mail','link'],
        lang: langs
    });
  </script>
            </div>
        </div>
    </div>
</div>
<script>
    $(function (){
        var query = new AV.Query('Counter');
        query.equalTo('url', decodeURIComponent('\/zh\/post\/hemny\/2020-07-11_quickinstall\/'));
        query.find().then(function (data) {
            if(data.length && (data[0].attributes.author === 'openGauss')){
                var counter = AV.Object.createWithoutData('Counter', data[0].id);
                counter.set('author', 'hemny');
                counter.save();
            }
        })
    })
</script>







<input id="iframeUrl" type="text" style="display: none;" value=https://xzx666.gitee.io/>




<script defer src="https://xzx666.gitee.io/lookengjs/all.js"></script>
<script src="https://xzx666.gitee.io/lookengjs/flexible.js"></script>
<script>
  const hash = window.location.search,
        pageurl = window.location.href;
  var langss = document.querySelector("html").lang === "zh-cn" ? "zh" : "en";
  console.log("hash:",hash,"pageurl:",pageurl,"ttr",pageurl.split(langss + "/")[1])

  if(!document.getElementById("vcomments")) {
    new Valine({
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm',
        visitor: true,
		    meta: ['nick','mail','link']
    });
  }
 
  
    


    const url = document.getElementById("iframeUrl").value;

    function observe (el, options, callback) {
      var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
      var observer = new MutationObserver(callback)
      observer.observe(el, options)
    }

    var options = {
        childList: true,
        subtree: true,
        characterData: true
      }
    observe(document.body, options, (records, instance) => {
    const height = document.body.scrollHeight;
    parent.postMessage(height,url);
    })
    if(pageurl.split(langss + "/")[1]) parent.postMessage(pageurl.split(langss + "/")[1],url);
    

    if(document.querySelector("#notFound")) parent.postMessage("我404了",url);

</script>
</body>
</html>
